/*
 * Tic-Tac-Toe - Turn-based strategy game
 * Copyright 2008, 2009 Shayne Riley and Paul Maseberg
 *
 * Tic-Tac-Toe is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tic-Tac-Toe is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tic-Tac-Toe.  If not, see <http://www.gnu.org/licenses/>
 * or write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * To contact the authors on questions or issues regarding the license,
 * you may send an email to <shayner at gmail dot com>
 */

#ifndef BOARDDISPLAY_H_
#define BOARDDISPLAY_H_

#include "GameBoard.h"
#include "Graphics.h"
#include "Audio.h"
#include "Button.h"

class BoardDisplay
{
public:
    /**
     * Constructor which will let the the board display at the coordinates.
     * @param gfx	The graphics system that board display uses to draw to
     * 	the screen.
     * @param aud   The audio system to play the various songs and sounds.
     * @param leftX	The left side of the board starts being drawn here.
     * @param lowerY	The lower side of the board starts being drawn here.
     * @param width	The width to draw the board.
     * @param height The height to draw the board.
     */
    BoardDisplay(Graphics *gfx, Audio *aud,
            int leftX, int lowerY, int width, int height);

    virtual ~BoardDisplay();

    /**
     * Retrieves a copy of the game board. Or maybe it won't be a copy, who cares.
     *
     * @return a game board.
     */
    GameBoard getBoard();
    /**
     * Loads in the new contents of the game board.
     * @param board	The board state to draw with.
     */
    void updateBoard(GameBoard& board);

    /**
     * Reads recent user input and draws the game board.
     */
    void update();

private:
    Graphics *mGfx;
    Audio *mAud;
    int mLeftX;
    int mLowerY;
    int mWidth;
    int mHeight;
    GameBoard mBoard;
    Button mSpots[3][3];

    void checkControls();
    void drawGrid();
    void drawMarkers();
    void drawWinner();      ///< Draws the winning line.
};

#endif /* BOARDDISPLAY_H_ */
